const fs= require('fs')
const path = require('path')
const parseUrl = require('parseurl')
const {readSource} = require('./readSource')

const vueMiddleware = ()=>{
    return async (req,res,next)=>{
        // req 文件 后缀
        if(req.path.endsWith('vue')){
            console.log(2)
        }
        else if(req.path.endsWith('js')){
            // console.log('----')
            const key = parseUrl(req).pathname;
            // console.log(key)
            const result = await readSource(req);
            console.log(result)
        }
        next()
    }
}

exports.vueMiddleware = vueMiddleware